#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <algorithm>
#include <time.h>
#include <iterator>
#include <functional>
#include <string>

using namespace std;

class Man
{
	string name;
	int age;
public:
	Man(const string & _name,int _age)
	{
		name=_name;
		age=_age;

	}
	friend ostream & operator<<(ostream & os,const Man & obj);
	void print()
	{
		cout<<"Name: "<<name<<endl<<"age: "<<age<<endl;

	}
	bool operator<(const Man&obj2)
	{
		if(obj2.age<age)
		return false;
		else 
			return true;
	}
		
	class NameEquals :public unary_function<Man,bool>
	{
		string str;
	public:
		NameEquals(const string & _str):str(_str){}

		bool operator()(const Man& obj)
		{
			return str==obj.name;
		}
	};
	class Equals:public unary_function<Man,bool>
	{
		string str;
	public:
		Equals(const string _str):str(_str){}
		bool operator()(const Man & obj)
		{
			if(obj.name.find(str)!=string::npos)
			{
				return true;
			}
			else
				return false;
		}


	};
};
ostream & operator<<(ostream & os,const Man & obj)
{
	os<<"Name: "<<obj.name<<endl<<"age: "<<obj.age<<endl;
	return os;
}
void main ()
{
	Man a("Vasya",19), b("Sveta",23), c("Zhora",18);
	vector<Man> people;
	people.push_back(a); people.push_back(b);people.push_back(c);
	copy(people.begin(),people.end(),ostream_iterator<Man>(cout,"\n"));
	cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
	sort(people.begin(),people.end());
	copy(people.begin(),people.end(),ostream_iterator<Man>(cout,"\n"));
	vector <Man> ::iterator found = find_if(people.begin(),people.end(),Man::NameEquals("Vasya"));
	
		cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;if(found!=people.end())
	{
		cout<<*found<<endl;

	}
	else
	{
		cout<<"Not Found\n"<<endl;
	}
		
		vector <Man> ::iterator f = find_if(people.begin(),people.end(),Man::Equals("a"));
		cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
		if(f!=people.end())
	{
		cout<<*f<<endl;

	}
	else
	{
		cout<<"Not Found\n"<<endl;
	}
}